package com.javaAdmin.quartz;

import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置定时任务包
 *
 * @author Administrator
 */
@Configuration
public class JobConfig {
    @Bean
    public JobDetail quartzTask1JobDetail() {
        return JobBuilder.newJob(QuartzTask1.class)
                .withIdentity(QuartzTask1.class.getName())
                .storeDurably()  //开启持久化
                .build();
    }

    @Bean
    public Trigger quartzTask1JobTrigger() {
        return TriggerBuilder.newTrigger()
                .forJob(QuartzTask1.class.getName())
                //withSchedule 设置运行计划
                .withSchedule(CronScheduleBuilder.cronSchedule("0/5 * * * * ?"))
                .build();
    }

    @Bean
    public JobDetail quartzTask2JobDetail() {
        return JobBuilder.newJob(QuartzTask2.class)
                .withIdentity(QuartzTask2.class.getName())
                .storeDurably()  //开启持久化
                .build();
    }

    @Bean
    public Trigger quartzTask2JobTrigger() {
        return TriggerBuilder.newTrigger()
                .forJob(QuartzTask2.class.getName())
                //withSchedule 设置运行计划
                .withSchedule(CronScheduleBuilder.cronSchedule("0/5 * * * * ?"))
                .build();
    }
}
